package com.thb.pay.core.builder;

/**
 * @类名称 BeanBuilder
 * @类描述 <pre>构建模式</pre>
 * @作者 lucky
 * @创建时间 2019/8/29
 * @版本 v1.01
 */
public class TestBean {

    private Integer id;

    private String name;

    public TestBean(Builder builder) {
        this.id = builder.id;
        this.name = builder.name;
    }

    public static void main(String[] args) {
        TestBean testBean = new TestBean.Builder().id(1).name("lucky").build();
        
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static final class Builder {

        private Integer id;

        private String name;

        public Builder() {
        }

        public Builder id(Integer id) {
            this.id = id;
            return this;
        }

        public Builder name(String name) {
            this.name = name;
            return this;
        }

        public TestBean build() {
            return new TestBean(this);
        }
    }
}
